﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace WpfBinding
{
    /// <summary>
    /// ModelBinding.xaml 的交互逻辑
    /// </summary>
    public partial class ModelBinding : Page
    {
        TestModelInfo model;
        TestModels models;

        public ModelBinding()
        {
            InitializeComponent();

            model = new TestModelInfo();
            tb.DataContext = model;
            
            models = new TestModels();
            listBox2.ItemsSource = listBox1.ItemsSource = models;

            textBlock1.DataContext = models;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            model.Age += 1;
            models.Add(new TestModelInfo() { Age = model.Age });
        }
    }
}
